package com.czkt.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.czkt.entity.Product;
import com.czkt.service.IProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jobob
 * @since 2024-06-18
 */
@Controller
public class ProductController {
    @Resource
    IProductService productService;

    @RequestMapping("/product/list")
    public String productShow(@RequestParam(value = "prodName",defaultValue = "") String prodName,
                              @RequestParam(value = "prodType",defaultValue = "") String prodType,
                              @RequestParam(value = "prodBatch",defaultValue = "") String prodBatch,
                              @RequestParam(value = "pageIndex",defaultValue = "1") Integer pageIndex,
                              @RequestParam(defaultValue = "3") Integer pageSize, Model model){
        IPage<Product> productIPage = productService.selectProduct(prodName,prodType,prodBatch,pageIndex,pageSize);
        model.addAttribute("productPage",productIPage);
        model.addAttribute("prodName",prodName);
        model.addAttribute("prodType",prodType);
        model.addAttribute("prodBatch",prodBatch);
        return "/product/list";
    }
}
